from django.contrib import admin

from .models import Network, Station
from instrument.models import InstrumentItem, SeismicInstrumentEntity
from .forms import StationForm

admin.site.site_header = "台站运维日志管理系统"
admin.site.site_title = "台站运维日志管理系统"
admin.site.index_title = "欢迎使用台站运维日志管理系统"


@admin.register(Network)
class NetworkAdmin(admin.ModelAdmin):
    '''Admin View for Network'''

    list_display = (
        'code',
        'name',
    )
    list_display_links = ('code', )
    ordering = ('code', )
    prepopulated_fields = {'slug': ('code', )}


class InstrumentItemInline(admin.TabularInline):
    model = InstrumentItem


# class SeismicInstrumentEntityInline(admin.TabularInline):
#     model = SeismicInstrumentEntity


@admin.register(Station)
class StationAdmin(admin.ModelAdmin):
    '''Admin View for Station'''
    form = StationForm
    # fieldsets = (
    #     ('主要信息', {
    #         'fields': (
    #             'net',
    #             'code',
    #             'name',
    #             (
    #                 'latitude',
    #                 'longitude',
    #                 'altitude',
    #             ),
    #             'slug',
    #             'status',
    #         )
    #     }),
    #     ('扩展信息', {
    #         'classes': ('collapse', ),
    #         'fields': (
    #             'establish',
    #             'removal',
    #             'remark',
    #         )
    #     }),
    # )

    # list_display = ('net', 'code', 'name', 'latitude', 'longitude', 'altitude',
    #                 'status')
    # list_display_links = ('code', )
    # list_filter = ('status', )
    # ordering = (
    #     'net',
    #     'code',
    # )
    # prepopulated_fields = {
    #     'slug': (
    #         'net',
    #         'code',
    #     )
    # }
    # inlines = (InstrumentItemInline, )
